/* Copyright © 2010 LPRM
Universidade Federal do Espírito Santo - RNP-GT CWTools

This file is part of GW-Android.

GW-Android is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

GW-Android is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with GW-Android. If not, see <http://www.gnu.org/licenses/>. */
package br.ufes.cwtools.gw.android.components;

public class RequiredComponent implements Comparable<RequiredComponent>{
	private String name;
	private String description;
	private String version;
	private long size;
	private String packageName;
	private String md5Hash;
	private String baseUrl;

	public String getBaseUrl() {
		return baseUrl;
	}
	
	public void setBaseUrl(String baseUrl) {
		this.baseUrl = baseUrl;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public String getDescription() {
		return description;
	}
	
	public void setDescription(String description) {
		this.description = description;
	}
	
	public String getVersion() {
		return version;
	}
	
	public void setVersion(String version) {
		this.version = version;
	}

	public String getSize() {
		double tam = size;
		
		String unidade = " bytes";
		if (tam >= 1024){
			tam /= 1024;
			if(tam < 1024){
				unidade = " KB";
			}else{
				tam /= 1024;
				unidade = " MB";
			}
		}
		return String.format("%.2f %s", tam, unidade);
	}
	
	public void setSize(long size) {
		this.size = size;
	}
	
	public String getPackageName() {
		return packageName;
	}

	public void setPackageName(String packageName) {
		this.packageName = packageName;
	}
	
	public String getMd5Hash() {
		return md5Hash;
	}
	
	public void setMd5hash(String md5hash) {
		this.md5Hash = md5hash;
	}

	@Override
	public int compareTo(RequiredComponent another) {
		return name.compareTo(another.getName());
	}
}
